package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	c := make(chan struct{})
	var size int64
	var path = "D:\\桌面\\collect\\tqLogger\\trackx\\track-2024-07-18-19.log"
	file, err := os.Stat(path)
	if os.IsNotExist(err) {
		fmt.Printf("Error! %s not found\n", path)
		os.Exit(1)
	}
	go func() {
		for {
			if file.Size() != size {
				c <- struct{}{}
				break
			}
		}
	}()
	go func() {
		for {
			select {
			case <-c:
				f, err := os.Open(path)
				if err != nil {
					println(err.Error())
				}
				all, err := io.ReadAll(f)
				if err != nil {
					println(err.Error())
				}
				println(string(all))
				f.Close()
			}
		}
	}()
	select {}
	//seek := &tail.SeekInfo{Offset: 0, Whence: io.SeekEnd}
	//t, err := tail.TailFile(path, tail.Config{
	//	Follow:   true,
	//	Location: seek,
	//})
	//if err != nil {
	//	fmt.Println(err)
	//}
	//for line := range t.Lines {
	//	fmt.Println(line.Text)
	//}
}
